/*
 * Copyright 2021 The Kubernetes Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@import 'mixins';
@import '../Editor/mixins';

$tooltip-fgcolor: var(--color-base00);
$tooltip-fgcolor-dark: var(--color-text-01);
$tooltip-bgcolor: var(--color-base0D);

@include Tooltip {
  --tooltip-fgcolor: #{$tooltip-fgcolor};
  color: var(--tooltip-fgcolor);
  background-color: $tooltip-bgcolor;
  filter: grayscale(0.85);

  &[data-is-markdown] {
    @include EditorInMarkdown {
      background: transparent !important;
    }
    @include EditorBackground {
      background: transparent !important;
    }

    .pf-c-content {
      font-size: inherit;
    }
    .pf-c-tooltip__content {
      padding: 0;
      font-size: 0.75rem;
      background-color: transparent;
    }

    h1,
    h2,
    h3,
    h4,
    p {
      font-size: inherit;
      padding: var(--pf-c-tooltip__content--PaddingTop) var(--pf-c-tooltip__content--PaddingRight)
        var(--pf-c-tooltip__content--PaddingBottom) var(--pf-c-tooltip__content--PaddingLeft);
    }

    h3 {
      padding-bottom: 0;
      line-height: 1.625em;
    }
    h3 + h4 {
      margin: 0;
      padding-top: 0;

      a:only-child {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }

    p {
      padding-top: 0;
    }

    p + p {
      padding-top: 0;
    }

    code {
      opacity: 0.9;
      color: var(--tooltip-fgcolor);
      font-family: var(--font-sans-serif);
    }

    a[href] {
      color: var(--color-base0F);
    }
  }

  & > div {
    color: var(--tooltip-fgcolor);
    background-color: $tooltip-bgcolor;
  }

  h1,
  h2,
  h3,
  h4 {
    color: var(--tooltip-fgcolor);
    padding-top: 0;
    font-size: inherit;
  }

  h3 {
  }

  h4 {
    font-weight: normal;

    &:not(:last-child) {
      border-bottom: 1px solid var(--color-base02);
    }
  }

  hr {
    margin: 0.5em 0;
  }
}
